{% extends "admin/base_site.html" %}
{% load i18n admin_urls static %}

{% block extrahead %}
    {{ block.super }}
    <style>
        .upload-form {
            margin: 20px 0;
            padding: 20px;
            background-color: #f8f8f8;
            border-radius: 5px;
        }
        .help-text {
            margin: 15px 0;
            padding: 15px;
            background-color: #e8f4f8;
            border-left: 4px solid #5bc0de;
        }
        .template-download {
            margin: 15px 0;
        }
        .submit-row {
            margin-top: 20px;
        }
    </style>
{% endblock %}

{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label='product' %}">{% trans 'Product' %}</a>
&rsaquo; <a href="{% url 'admin:product_product_changelist' %}">{% trans 'Products' %}</a>
&rsaquo; {% trans 'Upload Products' %}
</div>
{% endblock %}

{% block content %}
<div id="content-main">
    <h1>{% trans "Upload Products from Excel" %}</h1>
    
    <div class="help-text">
        <h3>{% trans "Instructions:" %}</h3>
        <ul>
            <li>{% trans "Download the template Excel file below" %}</li>
            <li>{% trans "Fill in the product information according to the template" %}</li>
            <li>{% trans "Upload the completed Excel file" %}</li>
            <li>{% trans "The system will process the file and create products" %}</li>
        </ul>
    </div>
    
    <div class="template-download">
        <a href="{% url 'admin:product_excel_template' %}" class="button">{% trans "Download Template" %}</a>
    </div>
    
    <div class="upload-form">
        <form action="." method="post" enctype="multipart/form-data">
            {% csrf_token %}
            
            {% if form.errors %}
                <p class="errornote">
                {% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
                </p>
                {{ form.non_field_errors }}
            {% endif %}
            
            <div class="form-row">
                {{ form.excel_file.errors }}
                <label for="id_excel_file">{% trans "Excel File:" %}</label>
                {{ form.excel_file }}
                <p class="help">{% trans "Select an Excel file (.xlsx) containing product information." %}</p>
            </div>
            
            <div class="submit-row">
                <input type="submit" value="{% trans 'Upload' %}" class="default" name="_upload">
            </div>
        </form>
    </div>
    
    {% if messages %}
    <ul class="messagelist">
        {% for message in messages %}
            <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
        {% endfor %}
    </ul>
    {% endif %}
</div>
{% endblock %}
